/**
 *@description: 华夏银行信用卡，抓取流程包装处理
 *@author: LiTao
 *@date:2018/09/25
 */


/**
 * @description: 华夏银行信用卡抓取、解析主流程
 */

//账单日(  例子:抓取到"每月15日" ，则账单日为 15)
var global_billD_date="";

var hxb_credit_handle={

    /**
     * @description: 华夏信用卡抓取\解析主方法
     * @param indexNum  序号
     * @param baseInfoLine 用户基础信息行
     */
    hxb_credit_main:function(indexNum,baseInfoLine){
        //卡数据对象
        var creditCardAllData = new CreditCardAllData();
        //开户行
        creditCardAllData.setOpenBank(baseInfoLine.get(5).text());

        //抓取卡用户基础信息（信用卡额度和持卡人）
        this.crawlBaseUserInfo(indexNum,creditCardAllData);

        //解析卡用户基础信息
        this.parseBaseUserInfo(creditCardAllData);

        var undoneAndDoneBeforHtml =  ajax_get(credit_urls.UNDO_PARAM_URL);
        storeDataToFile(context, undoneAndDoneBeforHtml,  "undoneAndDoneBeforHtml.html");

        var undoneAndDoneBeforDoc = Jsoup.parse(undoneAndDoneBeforHtml);
        //解析出两个请求参数
        var randomTokenVerifyTag  = undoneAndDoneBeforDoc.select("#randomTokenVerifyTag").attr("value");
        var verifyCodeBackUriTag =  undoneAndDoneBeforDoc.select("#verifyCodeBackUriTag").attr("value");

        //抓取已出账单
        this.crawlDONE(indexNum,randomTokenVerifyTag,verifyCodeBackUriTag);

        //存放未出账单、已出账单列表
        var doneAndUndoBillList = new ArrayList();
        creditCardAllData.setBills(doneAndUndoBillList);

        //解析已出账单
        this.parseDONE(doneAndUndoBillList,creditCardAllData);

        //抓取未出账单
        var undoPageXml=this.crawlUNDO(indexNum,randomTokenVerifyTag,verifyCodeBackUriTag);

        //解析未出账单
        this.parseUNDO(undoPageXml,doneAndUndoBillList,creditCardAllData);
        return creditCardAllData;
    },

/*********************************封装不同业务数据的抓取、解析具体方法****************************************/
    /**
     * 抓取卡列表
     */
    crawlCardInfo:function () {

    },


    /**
     * 解析卡列表信息
     */
    parseCardInfo:function () {

    },

    /**
     * 抓取卡用户基础信息
     */
    crawlBaseUserInfo:function(indexNum){
        // 请求参数
        var balanceMap = new HashMap();
        balanceMap.put("randomTokenVerifyTag","ae210eabcaf87cc7dfda5a6af80d10a6");
        balanceMap.put("verifyCodeBackUriTag","%2Fjsp%2Fsafeguard%2Ftokeninvalid.jsp");
        balanceMap.put("accountName","1");

        //（信用卡额度和持卡人）
        var html = ajax_post(credit_urls.USER_DETAIL_URL,balanceMap);
        storeDataToFile(context, html, indexNum + "_cardEdu_1.html");

        //卡片信息
        var cardHtml = ajax_get(credit_urls.CARD_DETAIL_URL);
        storeDataToFile(context, cardHtml, indexNum + "_cardFullCardNum_1.html");

        //开卡银行
        var openTimeHtml = ajax_get(credit_urls.OPEN_BANK_URL);
        storeDataToFile(context, openTimeHtml, indexNum + "_cardOpenTime_1.html");

        //放入上下文
        context.put("BASE_USER_INFO",html);
        context.put("CARD_DETAIL",cardHtml);
        context.put("OPEN_BANK",openTimeHtml);
    },


    /**
     * 解析卡用户基础信息
     */
    parseBaseUserInfo:function(creditCardAllData){

     try {
        creditCardAllData.setBankName("华夏银行");
        creditCardAllData.setCardId(UUID.randomUUID().toString());
        creditCardAllData.setCardType("信用卡");

        //基础信息页
        var baseUserInfoHtml=context.get("BASE_USER_INFO");
        //卡信息页
        var cardHtml=context.get("CARD_DETAIL");
        //开户行页面
        var openBankHtml=context.get("OPEN_BANK");

        var  openTime = Jsoup.parse(openBankHtml).select("td.eventd:nth-child(6)").text();
        creditCardAllData.setOpenTime(StringUtils.isBlank(openTime)?"":yyyy_MM_dd_PARSER.parse(openTime));

        //基础信息页
        var doc = Jsoup.parse(baseUserInfoHtml);
        var tableElements = doc.select("table[class=inputStyleTable]");
        for each(var el in tableElements){
            var tds = el.getElementsByTag("tr");
            creditCardAllData.setNameOnCard(tds.get(0).text().replaceAll("姓名", "").replaceAll("\\s*", "").trim());
            creditCardAllData.setCreditLimit(stringToBigDecimal(tds.get(1).text().replaceAll("信用额度", "").trim().replaceAll(",", "")));
            creditCardAllData.setBalance(stringToBigDecimal(tds.get(2).text().replaceAll("可用额度", "").trim().replaceAll(",", "")));
            creditCardAllData.setCashLimit(stringToBigDecimal(tds.get(3).text().replaceAll("预借现金信用额度", "").trim().replaceAll(",", "")));
            creditCardAllData.setCashBalance(stringToBigDecimal(tds.get(4).text().replaceAll("预借现金可用额度", "").trim().replaceAll(",", "")));
        }

        //卡信息页
        var fullCardNumList = new ArrayList();
        var doc = Jsoup.parse(cardHtml);
        var tableElement = doc.getElementById("accountDetailQueryDisplayVBList_row");
        var tbody = tableElement.select("tbody");
        var trs = tbody.select("tr");
        for (var i = 0; i < trs.size(); i++) {
            var tds = trs.get(i).select("td");
            var currentType = tds.get(4).text();

            if ("华夏信用卡".equals(currentType)){
                // 卡号
                var fullCardNum = RegexUtils.GetText(tds.get(1).text(), "\\d*");
                fullCardNumList.add(fullCardNum);
                // if(fullCardNum.endsWith(card_num)){
                creditCardAllData.setFullCardNum(list2String(fullCardNumList));
                // 卡号后四位
                creditCardAllData.setCardNum(getCardNumList(fullCardNumList));
            }
        }
        } catch (e) {
            logger.error("华夏信用卡用户基础信息解析异常,行【"+e.lineNumber+"】异常信息【"+e.message+"】");
        }
        return;


        /**
         * 卡号集合
         * @param list
         * @return
         */
        function list2String(list) {
            var sb = new StringBuffer();
            for each(var str in list){
                sb.append(str).append(",");
            }
            return sb.toString().trim().substring(0, sb.toString().length() - 1);
        }

        /**
         * 卡号后四位
         * @param cardNumList
         * @return
         */
        function getCardNumList(cardNumList) {
            var sb = new StringBuffer();
            for each(var cardNum in cardNumList){
                sb.append(cardNum.substring((cardNum.length() - 4), (cardNum.length()))).append(",");
            }
            return sb.toString().trim().substring(0, sb.toString().length() - 1);
        }
    },

    /**
     * 抓取未出账单
     */
    crawlUNDO:function(indexNum,randomTokenVerifyTag,verifyCodeBackUriTag){
        var now = LocalDateTime.now();
        var year = now.getYear();
        year = Integer.parseInt(year);
        var  month =  now.getMonthValue();
        month = Integer.parseInt(month);
        var day =  now.getDayOfMonth();
        day = Integer.parseInt(day);
        var undoneMap = new HashMap();
        undoneMap.put("randomTokenVerifyTag",randomTokenVerifyTag);
        undoneMap.put("verifyCodeBackUriTag",verifyCodeBackUriTag);
        undoneMap.put("cardNo","1%7C2");
        undoneMap.put("queryStrDateYear",year);
        undoneMap.put("queryStrDateMonth",month);
        undoneMap.put("queryStrDateDay","01");
        undoneMap.put("db_current_time_year",year);
        undoneMap.put("db_current_time_month",month);
        undoneMap.put("db_current_time_day",day);
        undoneMap.put("queryEndDateYear",year);
        undoneMap.put("queryEndDateMonth",month);
        undoneMap.put("queryEndDateDay",day);
        undoneMap.put("db_current_time_year",year);
        undoneMap.put("db_current_time_month",month);
        undoneMap.put("db_current_time_day",day);
        undoneMap.put("queryMode","0");
        undoneMap.put("billYearMonYear",year);
        undoneMap.put("billYearMonMonth",month);
        var　undoHtml =  ajax_post(credit_urls.BILLUNDONE_URL,undoneMap);
        storeDataToFile(context, undoHtml, indexNum + "_unDonePage_1.html");

        var doc = Jsoup.parse(undoHtml);
        var eleXmlList= doc.select("span[class=export xml]");

        if (eleXmlList.size() != 0) {
            var span = eleXmlList.get(0);
            var downLoadUrl = span.parent().attr("href");
            if (StringUtils.isNotBlank(downLoadUrl)) {
                //未出账单xml页
                var undoPageXml = ajax_get("https://sbank.hxb.com.cn/" + downLoadUrl);
                storeDataToFile(context, undoPageXml, indexNum + "_unDonePage_1.xml");
                //返回有数据的xml
                return undoPageXml;
            }
        }
        //否则返回空
        return null;
    },

    /**
     * 解析未出账单
     * @param undoPageXml
     * @param doneAndUndoBillList
     * @param creditCardAllData
     */
    parseUNDO:function(undoPageXml,doneAndUndoBillList,creditCardAllData){
        // 存放消费记录
        var shopping_sheets = new ArrayList();
        var billAllData = new BillAllData();

        //解析未出账单,表头数据
        parseUndoBaseData(billAllData,creditCardAllData);

        //解析未出账单,购物账单明细
        parseUndoShoppingSheets(undoPageXml,billAllData,shopping_sheets);
        //添加
        doneAndUndoBillList.add(billAllData);
        return;

        /**
         * 解析未出账单,表头数据
         */
        function parseUndoBaseData(billAllData,creditCardAllData){
            try {
                billAllData.setBankName("华夏银行");
                billAllData.setBillId(UUID.randomUUID().toString());
                // var installments = new ArrayList();
                // billAllData.setInstallments(installments);
                var calendar = Calendar.getInstance();
                //当前日
                var day = calendar.get(Calendar.DAY_OF_MONTH);
                day = Integer.parseInt(day);
                if (StringUtils.isNotBlank(global_billD_date)) {
                    //当前日>账单日   推后一个月作为未出账单月
                    if (day > Integer.parseInt(global_billD_date)) {
                        calendar.add(Calendar.MONTH, 1);
                    }
                }
                var billMonth = yyyy_MM_PARSER.format(calendar.getTime());
                billAllData.setBillMonth(billMonth);
                billAllData.setBillDate(yyyy_MM_dd_PARSER.parse(billMonth + "-" + global_billD_date));
                billAllData.setBillType("UNDONE");
                // 信用额度相关
                // billAllData.setCreditLimit(creditCardAllData.getCreditLimit());
                // billAllData.setCashLimit(creditCardAllData.getCashLimit());

                //这是上月的newBalance
                var lastBalance = context.get("newBalance");
                billAllData.setLastBalance((lastBalance !== "" && lastBalance !== null) ? new BigDecimal(lastBalance) : null);
            } catch (e) {
                logger.error("华夏信用卡未出账单表头数据解析异常,行【"+e.lineNumber+"】异常信息【"+e.message+"】");
            }
        }

        /**
         * 解析未出账单,购物账单明细
         * @param undoPageXml
         * @param billAllData
         * @param shopping_sheets
         */
        function parseUndoShoppingSheets(undoPageXml,billAllData,shopping_sheets){
            var sumMoney = 0.0;
            var newcharges = new BigDecimal(0);
            //存在未出账单数据
            if(undoPageXml!=null){
                try {
                    var undoneDoc = Jsoup.parse(undoPageXml);
                    var rows = undoneDoc.select("row");
                    for (var i = 0; i < rows.size(); i++) {
                        var columns = rows.get(i).select("column");
                        var expense = new Expense();
                        expense.setId(UUID.randomUUID().toString());
                        expense.setOrderIndex(Long.parseLong(columns.get(0).text()));// 索引
                        // 交易时间
                        expense.setTransDate(yyyy_MM_dd_HH_mm_ss_PARSER.parse(columns.get(1).text() + " 00:00:00"));
                        expense.setPostDate(yyyy_MM_dd_PARSER.parse(columns.get(2).text()));
                        expense.setCardNum(columns.get(6).text());// 卡号后四位
                        expense.setCurrencyType(convertCurr(columns.get(3).text()));// 交易币种

                        expense.setAmountMoney(stringToBigDecimal(columns.get(5).text().replaceAll(",", "")));// 交易金额
                        sumMoney = sumMoney + Double.parseDouble(columns.get(5).text().replaceAll(",", ""));
                        if (expense.getAmountMoney().signum() == 1) {
                            newcharges = newcharges.add(expense.getAmountMoney());
                        }
                        expense.setCategory(CategoryUtil.getCreditCategory("HXB", columns.get(4).text(), expense.getAmountMoney().toString()));
                        expense.setDescription(columns.get(4).text());
                        shopping_sheets.add(expense);
                    }

                    //循环结束，计算相关值
                    billAllData.setNewCharges(newcharges);
                    var lastBalance = context.get("newBalance")
                    if (lastBalance !== "" && lastBalance !== null) {
                        sumMoney = Double.parseDouble(lastBalance) + sumMoney;
                    }
                    billAllData.setNewBalance(new BigDecimal(String.format("%.2f", sumMoney)));
                    //添加未出购物
                    billAllData.setShoppingSheets(shopping_sheets);
                } catch (e) {
                    logger.error("华夏信用卡未出账单购物明细解析异常,行【"+e.lineNumber+"】异常信息【"+e.message+"】");
                }
            }
        }

        /**
         * 解析未出账单,分期明细
         * @param shoppingList  购物列表
         */
        function parseUndoInstallments(shoppingList){
            return parseInstallments(shoppingList);
        }
    },

    /**
     * 抓取已出账单
     */

    crawlDONE:function(indexNum,randomTokenVerifyTag,verifyCodeBackUriTag){
        //存放已出账单页面
        var doneHtmlList=new ArrayList();

        //存放已出账单xml页面
        var xmlPageMap=new HashMap();

        //构建过去6个月的抓取时间
        var timeList=this.buildLast6MonthTime();

        //抓取6个月的已出账单
        for(var k=0;k<timeList.size();k++){

            var crawlDate=timeList.get(k);
            //年份
            var year=crawlDate.substring(0, 4)
            //月份
            var month=crawlDate.substring(5, crawlDate.length);

            //构建已出账单请求参数
            var map = new HashMap();
            map.put("randomTokenVerifyTag",randomTokenVerifyTag);
            map.put("verifyCodeBackUriTag",verifyCodeBackUriTag);
            map.put("accountName","1");
            map.put("billYearMonYear",year);
            map.put("billYearMonMonth",month);
            //已出账单详情页
            var doneDetailHtml = ajax_post(credit_urls.BILLDETAIL_URL,map);
            storeDataToFile(context, doneDetailHtml,indexNum+"_bill" + year + month + "_1.html");
            //添加
            doneHtmlList.add(doneDetailHtml);

            var doc = Jsoup.parse(doneDetailHtml);
            var exporDoneXml = doc.select("span[class=export xml]");
            //存在帐单数据
            if(exporDoneXml.size() != 0){
                var href = exporDoneXml.get(0).parent().attr("href");
                var downLoadUrl = "https://sbank.hxb.com.cn" + href;
                //获取xml格式
                var doneXml = ajax_get(downLoadUrl);
                storeDataToFile(context,doneXml, year + "-" +month + "shoppingExpense.xml");
                xmlPageMap.put(crawlDate,doneXml);
            }
        }
        //加入上下文
        context.put("doneHtmlList",doneHtmlList);
        context.put("xmlPageMap",xmlPageMap);
        context.put("timeList",timeList);
        return;

    },

    /**
     * 解析已出账单
     * @param doneAndUndoBillList
     */
    parseDONE:function(doneAndUndoBillList,creditCardAllData){

        try {
            //从上下文取出相应数据
            var doneHtmlList = context.get("doneHtmlList");
            var xmlPageMap = context.get("xmlPageMap");
            var timeList = context.get("timeList");

            //遍历已出账单页
            for (var i = 0; i < timeList.size(); i++) {
                //账单实例
                var billAllData = new BillAllData();

                //获取已出账单页面
                var doneHtml = doneHtmlList.get(i);

                //解析已出账单表头数据
                parseDoneBillBaseData(i,billAllData, doneHtml,creditCardAllData);

                //存放购物明细
                var shopping_sheets = new ArrayList();
                //存放分期明细
                var installments = new ArrayList();

                var crawlDate=timeList.get(i);//已出账单xml页
                var donePageXml = xmlPageMap.get(crawlDate);

                if(donePageXml!=null&&donePageXml!=""){
                    //解析已出账单,购物账单明细
                    parseDoneShoppingSheets(shopping_sheets, installments, donePageXml);
                }
                //添加
                billAllData.setShoppingSheets(shopping_sheets);
                billAllData.setInstallments(installments);
                doneAndUndoBillList.add(billAllData);
            }
        } catch (e) {
            logger.error("华夏信用卡已出账单解析异常,行【"+e.lineNumber+"】异常信息【"+e.message+"】");
        }
        return;

        /**
         * 解析已出账单表头数据
         */
        function parseDoneBillBaseData(i,billAllData,doneHtml,creditCardAllData){
            try {
                logger.info("timeList="+timeList.toString())
                billAllData.setBillMonth(timeList.get(i));
                billAllData.setBankName("华夏银行");
                billAllData.setBillId(UUID.randomUUID().toString());// UUID随机生成
                billAllData.setBillType("DONE");// 无数据
                billAllData.setCashLimit(creditCardAllData.getCashLimit());
                billAllData.setCreditLimit(creditCardAllData.getCreditLimit());
                var doc = Jsoup.parse(doneHtml);
                if(global_billD_date==""){
                    var tableElements = doc.select("table[class=inputStyleTable]");
                    if (tableElements.size() > 0) {
                        var accStatements = tableElements.get(0).getElementsByTag("td");
                        var strg = accStatements.get(1).text().split(" ");
                        //获取页面账单日信息（页面数据格式  账单日:每月15日）
                        var billDate = strg[0].replaceAll("年", "-").replaceAll("月份", "-") + strg[2].replaceAll("：", "").replaceAll("每月", "").replaceAll("日", "");
                        //截取天
                        global_billD_date = billDate.substring(8, 10);
                        //账单日
                        billAllData.setBillDate(yyyy_MM_dd_PARSER.parse(timeList.get(i) + "-" + global_billD_date));// 账单日
                    }
                }else{
                    //账单日
                    billAllData.setBillDate(yyyy_MM_dd_PARSER.parse(timeList.get(i) + "-" + global_billD_date));// 账单日
                }
                var tableElements = doc.select("table[class=inputStyleTable]");
                var accStatements = tableElements.get(0).getElementsByTag("td");
                var strg = accStatements.get(1).text().split(" ");
                //到期还款日
                billAllData.setPaymentDueDate(yyyy_MM_dd_PARSER.parse(strg[4].replaceAll(":", "").replaceAll("：", "").trim()));
                // 人民币对账单
                tableElements = doc.select("table[class=table]");
                var rmbTds = tableElements.get(0).getElementsByTag("td");
                // ----------------币种-----------
                // var currency = convertCurr(rmbTds.get(0).text().trim());

                // 本期应还金额,即账单金额
                billAllData.setNewBalance(stringToBigDecimal(rmbTds.get(1).text().split(":")[1].replaceAll(",", "")));
                if (i == 0) {
                    //作为未出账单的上月还款金额
                    context.put("newBalance", rmbTds.get(1).text().split(":")[1].replaceAll(",", ""));
                }
                //logger.info("10月份newBalance:----{}",context.get("newBalance"));
                // 最低还款额
                billAllData.setMinPayment(stringToBigDecimal(rmbTds.get(2).text().split(":")[1].replaceAll(",", "")));
                // 本期账单余额表头
                tableElements = doc.select("table[class=simple]");
                // 本期对账单表格内容
                var tds = tableElements.get(0).getElementsByTag("td");
                // 上期账单余额
                billAllData.setLastBalance(stringToBigDecimal(tds.get(2).text().replaceAll(",", "")));
                // 本期实际还款
                // 本期新增款额
                var newCharges = stringToBigDecimal(tds.get(6).text().replaceAll(",", ""));
                billAllData.setNewCharges(newCharges);
                // 本期新增账款tds.get(6).text()
                // 上期还款金额 ---页面无数据
                billAllData.setLastPayment(stringToBigDecimal(tds.get(4).text().replaceAll(",", "")).negate());
                billAllData.setInterest(stringToBigDecimal(tds.get(10).text().replaceAll(",", "")));// 循环利息
               // return validMonthFlag;
            } catch (e) {
                logger.error("华夏信用卡已出账单表头解析异常,行【"+e.lineNumber+"】异常信息【"+e.message+"】");
            }
        }

        /**
         * 解析已出账单,购物账单明细
         * @param shopping_sheets
         * @param Installments
         * @param donePageXml
         */
        function parseDoneShoppingSheets(shopping_sheets,installments,donePageXml){

            try {
                var doneXmlDoc = Jsoup.parse(donePageXml);
                var rows = doneXmlDoc.select("row");
                for (var i = 0; i < rows.size(); i++) {
                    var row = rows.get(i);
                    //账单实例
                    var expense = new Expense();
                    var columns = row.select("column");
                    expense.setOrderIndex(Long.parseLong(columns.get(0).text()));// 设置序号
                    //交易日期
                    expense.setTransDate(yyyy_MM_dd_HH_mm_ss_PARSER.parse(columns.get(1).text() + " 00:00:00"));
                    //记帐日期
                    expense.setPostDate(yyyy_MM_dd_PARSER.parse(columns.get(2).text()));
                    //描述
                    expense.setDescription(columns.get(3).text());
                    //金额
                    expense.setAmountMoney(stringToBigDecimal(columns.get(4).text().replaceAll(",", "")));
                    //卡号
                    expense.setCardNum(columns.get(5).text());
                    expense.setId(UUID.randomUUID().toString());// 改为随机
                    expense.setCurrencyType("CNY");// 币种 人民币
                    expense.setTransAddr("");
                    expense.setTransMethod("");
                    expense.setTransChannel("");
                    expense.setRemark("");
                    expense.setOppositeBank("");
                    expense.setNameOnOppositeCard("");
                    expense.setOppositeCardNo("");
                    expense.setCategory(CategoryUtil.getCreditCategory("HXB", expense.getDescription(), expense.getAmountMoney().toString()));

                    //添加账单
                    shopping_sheets.add(expense);

                    //分期实例
                    var installment = new Installment();
                    if (expense.getDescription().contains("分期") && !expense.getDescription().contains("手续费") && !expense.getDescription().contains("转分期")) {
                        installment.setAmountMoney(expense.getAmountMoney());
                        installment.setShoppingsheetId(UUID.randomUUID().toString());
                        installment.setPostDate(expense.getPostDate());
                        installment.setTransDate(expense.getTransDate());
                        installment.setInstallmentDesc(expense.getDescription());
                        installment.setInstallmentType(installmentTypeChange(expense.getDescription()));
                        installment.setCurrencyType("CNY");
                        installment.setTransferfeeDesc("");
                        var bill = expense.getDescription();
                        var m=getGroup0("第(\\d+)期共(\\d+)期",bill);
                        if (m!=undefined&&m!="") {
                            // var month = Integer.parseInt(m.group(1));
                            // var total = Integer.parseInt(m.group(2));
                            //总分期数
                            installment.setTotalMonth("");
                            //当前分期数
                            installment.setCurrentMonth("");
                        }
                        //添加分期
                        installments.add(installment);
                    } else if (expense.getDescription().contains("手续费")) {
                        // 找到已经存在的分期
                        var targetInstallment = findExistInstallment(installments, expense.getDescription());
                        installment = targetInstallment !== null ? targetInstallment : new Installment();
                        installment.setHandingFee(expense.getAmountMoney());
                        installment.setHandingfeeDesc(expense.getDescription());
                    }
                }
            } catch (e) {
                logger.error("华夏信用卡已出账单购物明细解析异常,行【"+e.lineNumber+"】异常信息【"+e.message+"】");
            }

        }

        function findExistInstallment(installments, description) {
            for each(var installment in installments){
                if (equals(installment.getInstallmentDesc().split(" ")[0], description.split(" ")[0]) && !installment.getInstallmentDesc().contains("手续费")) {
                    return installment;
                }
            }
            return null;
        }
    },

    /**
     * 构建过去7个月的抓取时间
     */
     buildLast6MonthTime:function(){
        var timeList = new ArrayList();
        try {
            var calendar = Calendar.getInstance();
            //提前减去一个月，避免当月无数据的情况
            //calendar.add(Calendar.MONTH, -1);
            for (var i = 0; i < 7; i++) {
                timeList.add(yyyy_MM_FORMAT.format(calendar.getTime()));
                //前一个月
                calendar.add(Calendar.MONTH, -1);
            }
            return timeList;
        } catch (e) {
            logger.error("构建抓取时间异常,行【"+e.lineNumber+"】异常信息【"+e.message+"】");
        }
    }
}


